<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">

    <ui:composition template="/WEB-INF/templates/common/admin.xhtml">

        <ui:define name="title">Cargo Registration</ui:define>
        <h:head>
            <style>
                <!-- work around to fix selectonemenu bug in Chrome & Safari -->
                .ui-selectonemenu-label{
                    width:90% !important;
                }
            </style>
        </h:head>

        <ui:define name="content">

            <div class="ui-grid ui-grid-responsive">
                <div class="ui-grid-row">
                    <div class="ui-grid-col-3" id="leftCol"></div>
                    <div class="ui-grid-col-6" id="mainCol">

                        <br/>
                        <h:form id="dateForm">
                            <p:outputLabel value="3. Set the arrival deadline for this new #{bookingBackingBean.originName}-#{bookingBackingBean.destinationName} cargo " />
                            <hr/>

                            <h:panelGrid columns="2" styleClass="registrationPanelGrid" style="margin: 0 auto;">
                                <p:calendar id="deadline" value="#{bookingBackingBean.arrivalDeadline}" mindate="#{bookingBackingBean.today}" mode="inline" pattern="yyyy-MM-dd">
                                    <p:ajax event="dateSelect" listener="#{bookingBackingBean.deadlineUpdated}"/>
                                </p:calendar>
                            </h:panelGrid>

                            <h:panelGrid columns="2" id="durationPanel" styleClass="registrationPanelGrid" style="margin: 0 auto;" >
                                <p:outputLabel value="A journey can't start and end the same day!" rendered="#{bookingBackingBean.duration eq 0}"/>
                                <p:outputLabel value="Journey duration is one day." rendered="#{bookingBackingBean.duration eq 1}"/>
                                <p:outputLabel value="Journey duration is #{bookingBackingBean.duration} days." rendered="#{bookingBackingBean.duration gt 1}"/>
                            </h:panelGrid>

                            <hr/>   

                            <h:panelGrid columns="5" styleClass="registrationPanelGrid" style="margin: 0 auto;">
                                <p:commandButton value="Back" action="booking-destination" />
                                <p:commandButton value="Cancel" action="/admin/dashboard" />
                                <p:commandButton value="Book Cargo" id="bookBtn" action="#{bookingBackingBean.register()}" disabled="#{!bookingBackingBean.bookable}"/>
                            </h:panelGrid>

                        </h:form>
                    </div>

                    <div class="ui-grid-col-3" id="leftCol"></div>
                </div>
            </div>

        </ui:define>
    </ui:composition>
</html>
